#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3+10;
int d[maxn][maxn];

inline int min(int a, int b, int c){
    return min(min(a, b), c);
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    string a, b; cin >> a >> b;
    for (int i = 0; i <= a.size(); ++i) {
        for (int j = 0; j <= b.size(); ++j) {
            if(!i) d[i][j] = j;
            else if(!j) d[i][j] = i;
            else if(a[i-1]==b[j-1]) d[i][j] = d[i-1][j-1];
            else{
                d[i][j] = min(d[i-1][j-1], d[i-1][j], d[i][j-1])+1;
            }
        }
    }
    cout << d[a.size()][b.size()];
    return 0;
}